home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Examples / A-Z / Q / QuickTime / Simple QuickTime View / UMovieViewer.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  4.4 KB  |  139 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UMovieViewer.cp
  3. // Copyright © 1996 by Apple Computer, Inc. All rights reserved. 
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UMovieViewer__
  7. #include "UMovieViewer.h"
  8. #endif
  9.  
  10.  
  11. //----------------------------------------------------------------------------------------
  12. // Constants:
  13.  
  14. const OSType kSignature    = 'MS01';            // Application signature
  15. const OSType kFileType    = 'MooV';            // open Movie files only 
  16.  
  17. const cPlayEveryFrame = 1001;        
  18.  
  19. //========================================================================================
  20. // CLASS TMovieViewerApplication
  21. //========================================================================================
  22.  
  23.  
  24. #undef Inherited
  25. #define Inherited TApplication
  26.  
  27. #pragma segment AInit
  28. MA_DEFINE_CLASS_M1(TMovieViewerApplication, Inherited);
  29.  
  30. //----------------------------------------------------------------------------------------
  31. // TMovieViewerApplication::IMovieViewerApplication: 
  32. //----------------------------------------------------------------------------------------
  33. #pragma segment AInit
  34.  
  35. void TMovieViewerApplication::IMovieViewerApplication()
  36. {
  37.     this->IApplication(kFileType, kSignature);
  38.     
  39.     fLaunchWithNewDocument = FALSE;
  40.     
  41.     // So the linker doesn't dead strip class info 
  42.     
  43.     MA_REGISTER_CLASS(TMovieView);
  44.     MA_REGISTER_CLASS(TMovieController);
  45.  
  46.     // So my view will be substituted when MacApp® creates the "default view"
  47.     
  48.     MA_REGISTER_SIGNATURE(TMovieView, 'dflt');
  49.  
  50. } // TMovieViewerApplication::IMovieViewerApplication 
  51.  
  52. //----------------------------------------------------------------------------------------
  53. // TMovieViewerApplication::DoMakeDocument:
  54. //----------------------------------------------------------------------------------------
  55. #pragma segment AOpen
  56.             
  57. TDocument* TMovieViewerApplication::DoMakeDocument(    CommandNumber /*itsCommandNumber*/,
  58.                                                     TFile* itsFile) // Override 
  59. {
  60.     TMovieViewerDocument* aDocument = new TMovieViewerDocument;
  61.     
  62.     aDocument->IMovieViewerDocument(itsFile, kSignature);
  63.     return aDocument;
  64.  
  65. } // TMovieViewerApplication::DoMakeDocument 
  66.  
  67. //========================================================================================
  68. // CLASS TMovieViewerDocument
  69. //========================================================================================
  70.  
  71.  
  72. #undef Inherited
  73. #define Inherited TFileBasedDocument
  74.  
  75. #pragma segment AInit
  76. MA_DEFINE_CLASS_M1(TMovieViewerDocument, Inherited);
  77.  
  78. //----------------------------------------------------------------------------------------
  79. // TMovieViewerDocument::IMovieViewerDocument: 
  80. //----------------------------------------------------------------------------------------
  81. #pragma segment AOpen
  82.         
  83. void TMovieViewerDocument::IMovieViewerDocument(TFile* itsFile, OSType itsCreator)
  84. {
  85.     this->IFileBasedDocument(itsFile, itsCreator);
  86.     
  87.     //
  88.     //    create a TMovie using the document file
  89.     //
  90.     if(itsFile)
  91.     {
  92.         TMovie *movie = new TMovie;
  93.         movie->IMovie(itsFile);
  94.         fMovie = movie;
  95.     }
  96.     else
  97.         fMovie = NULL;
  98.  
  99. } // TMovieViewerDocument::IMovieViewerDocument 
  100.  
  101. //----------------------------------------------------------------------------------------
  102. // TMovieViewerDocument::Free: 
  103. //----------------------------------------------------------------------------------------
  104. #pragma segment AOpen
  105.         
  106. TMovieViewerDocument::~TMovieViewerDocument()
  107. {
  108.     fMovie = (TMovie*)FreeIfObject(fMovie);
  109. } // TMovieViewerDocument::~TMovieViewerDocument 
  110.  
  111. //----------------------------------------------------------------------------------------
  112. // TMovieViewerDocument::DoMakeViews: 
  113. //----------------------------------------------------------------------------------------
  114. #pragma segment AOpen
  115.  
  116. void TMovieViewerDocument::DoMakeViews(Boolean /*forPrinting*/) // Override 
  117. {
  118.     /*
  119.     **    get the default MacApp window
  120.     **    get the movie's frame
  121.     **    and set its size to that of the movie plus room for the scrollers
  122.     */
  123.     TView* aView = gViewServer->NewTemplateWindow(kDefaultWindowID, this);
  124.     
  125.     /*
  126.     **    get the default MacApp view in the window
  127.     **    and let it know about the movie
  128.     */    
  129.     TMovieView* movieView =(TMovieView*)aView->FindSubView(kIDDefaultView);
  130.     if(fMovie)
  131.         movieView->HaveMovie(fMovie);
  132.     
  133. } // TMovieViewerDocument::DoMakeViews 
  134.  
  135. //----------------------------------------------------------------------------------------
  136. // End of UMovieViewer.cp
  137.  
  138. #pragma segment Inline
  139.